/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Controllers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author BENSON
 */
public class ControllerAddAdmin {
     /**
     * variable and views declarations
     */
    Views.AddAdmin addA;
    Model.MainModel model;
    private ActionListener actionListener;
    
    
    /**
     * constructor for instantiating declared views
     */
    public ControllerAddAdmin( ){
        addA = new Views.AddAdmin();
        addA.setVisible(true);
        model=new Model.MainModel();
                          
    }     
    
     /**
      * Method to add actionListener to clicked button
      */
    
     public void control(){        
        actionListener = new ActionListener() {
              public void actionPerformed(ActionEvent actionEvent) {  
                  if(actionEvent.getSource()==addA.getSaveBtn()){
                        model.addAdmins(addA);
                  }
                  if(actionEvent.getSource()==addA.getCloseBtn()){
                  addA.setVisible(false);
                  
                  }
               }
              
        };                
        addA.getSaveBtn().addActionListener(actionListener);
        addA.getCloseBtn().addActionListener(actionListener);
        
    }
    
}
